home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / mcu / macros05.arc / MACROS05.MAC < prev    next >
Text File  |  1990-05-16  |  62KB  |  2,052 lines

  1.          PAGE
  2. ****************************************************************************
  3. *  macros05.mac   1.0
  4. *  -------------------------------------------------------------
  5. *  Module Name:        MACROS05 - M6805 Macros
  6. *  -------------------------------------------------------------
  7. *
  8. *  Description:
  9. *     This file contains macros and subroutines to support pseudo-registers
  10. *     on the 6805 that simulate registers and addressing modes available on
  11. *     the 68HC11.  It is suitable for "black box" operation, i.e., the
  12. *     macros may be used without knowledge of how they work.  A list of the
  13. *     supported macros follows.  Consult the individual macro headers for
  14. *     usage details and see the "Notes" below.
  15. *
  16. *         LDD       Load DREG
  17. *         STD       Store DREG
  18. *         ADDD      Add   DREG
  19. *         SUBD      Add   DREG
  20. *         CPD       Compare DREG
  21. *         LDAXY     Load  A via 16-bit pseudo-register (XREG or YREG)
  22. *         STAXY     Store A via 16-bit pseudo-register (XREG or YREG)
  23. *         LDXR      Load  XREG
  24. *         STXR      Store  XREG
  25. *         INCXR     Increment XREG
  26. *         DECXR     Decrement XREG
  27. *         CPXR      Compare XREG
  28. *         LDYR      Load  YREG
  29. *         STYR      Store  YREG
  30. *         INCYR     Increment YREG
  31. *         DECYR     Decrement YREG
  32. *         CPYR      Compare YREG
  33. *         DEC.B     Decrement byte
  34. *         DEC.W     Decrement word
  35. *         INC.B     Increment byte
  36. *         INC.W     Increment word
  37. *         MOV.B     Move byte
  38. *         MOV.W     Move word
  39. *         MOVE      Move block of memory
  40. *
  41. * General Information:
  42. *   The following pseudo-registers are supported.
  43. *     DREG = pseudo 16-bit accumulator (A,X registers, A is MS half)
  44. *     XREG = pseudo 16-bit index register
  45. *     YREG = pseudo 16-bit index register
  46. *
  47. *   The following terms are used.
  48. *     #          = specifies immediate addressing mode
  49. *     <address>  = address/value operand (absolute or immediate)
  50. *     <offset>   = unsigned 16-bit offset for indexed addressing
  51. *
  52. *  Notes:
  53. *     1. Motorola reserves the right to make changes to this file.
  54. *        Although this file has been carefully reviewed and is believed
  55. *        to be reliable, Motorola does not assume any liability arising
  56. *        out of its use.  This code may be freely used and/or modified at
  57. *        no cost or obligation by the user.
  58. *     2. This file was made for use with the Motorola Development Systems
  59. *        MC6805 Portable Assembler/Linker for MS-DOS, known as PASM05 and
  60. *        PLD, as released on 82HCVBASM B* and 82HCVBLNK B*.  Consult the
  61. *        PASM and PLD reference manuals, part numbers M68HASM/D1 and
  62. *        M68HLINK/D1, for more details.
  63. *     3. These macros were made for ABSOLUTE assemblies only, i.e., for
  64. *        use with ORG directives.  While most of the macro concepts will
  65. *        work in relocatable assemblies (BSCT, DSCT, PSCT, ASCT, XDEF,
  66. *        and XREF), errors will be generated because PASM limits the use
  67. *        of external symbols in expressions and because the value of an
  68. *        expression must be known at assembly time for IFxx directives to
  69. *        assemble the proper code.  The first restriction is a result of
  70. *        limitations in the COFF object file format.  If it is desired to
  71. *        have these macros work with relocatable assemblies, modifica-
  72. *        tions similar to below should be made, but be forewarned of the
  73. *        increased inefficiencies in size and speed.  Consider the
  74. *        following code to change the LDD macro so that an XREF parameter,
  75. *        \1, can be loaded as an immediate value.
  76. *                         LDA      \.8
  77. *                         LDX      \.8+1
  78. *                         BRA      \.9
  79. *                \.8      FDB      \1
  80. *                \.9      EQU      *
  81. *     4. In order to efficiently support both LOAD and STORE operations
  82. *        for the pseudo 16-bit index registers, there are actually two
  83. *        such "registers", i.e., one for LOAD and one for STORE as
  84. *        defined below.  These routines maintain both "registers" with
  85. *        the same value, and so the programmer may think of them as one
  86. *        register.
  87. *               XREG1$  = 16-bit XREG for LOAD  operations
  88. *               XREG2$  = 16-bit XREG for STORE operations
  89. *               YREG1$  = 16-bit YREG for LOAD  operations
  90. *               YREG2$  = 16-bit YREG for STORE operations
  91. *     5. These macros can be used to create in-line code (speed
  92. *        efficient) or they be placed in a subroutine (byte efficient).
  93. *     6. Instruction modified code is used here and is denoted by use
  94. *        of the unique string "0-0" (RAM subroutines).
  95. *     7. Some macros use temporary storage locations (TEMPA$, TESTA$,
  96. *        etc.), so these macros should not be used in any interrupt
  97. *        routine in order to avoid corrupted values!
  98. *     8. The user must ensure that the code is appropriately placed in
  99. *        the target M6805's memory map, i.e., the RAM subroutines MUST
  100. *        be located in RAM but must not overlap the stack area ($00C0-
  101. *        00FF) unless it can be GUARANTEED there is no conflict!  See
  102. *        LO$MEM below to set low memory data storage area!
  103. *     9. To use this file, either use an INCLUDE statement or just
  104. *        merge this file into your source code file.  Consult your
  105. *        assembler's user's manual for the details specific to your
  106. *        situation.  When using a ROM controlled system, the MOVE
  107. *        macro should be used to copy the RAM subroutines from ROM to
  108. *        RAM (see the comments after where RAMSBR$ is defined below
  109. *        and note the INCLUDE statement for the RAMSBR.INI file).
  110. *        Reference the code segment example below for usage ideas
  111. *        (shown in PASM05 for MS-DOS syntax).
  112. *
  113. *                 ORG      $50
  114. *        TOTAL    RMB      2
  115. *        RTABLE   RMB      5
  116. *                 INCLUDE  MACROS05.MAC
  117. *
  118. *                 ORG      $400
  119. *        RESET    RSP
  120. *                 MOVE     #,.RAMSBR$,#,RAMSBR$,#,RAMSZ$  Init ram.
  121. *        START    MOV.W    #,0,TOTAL
  122. *                 LDD      COST
  123. *                 ADDD     #,1000
  124. *                 SUBD     #,ADJUST
  125. *                 ADDD     TOTAL
  126. *                 STDD     TOTAL
  127. *                 CPD      #,1500
  128. *                 BEQ      MATCH
  129. *        *
  130. *                 LDXR     #,0
  131. *                 LDYR     #,0
  132. *        LOOP     LDAXY    TABLE,XREG
  133. *                 STAXY    RTABLE,YREG
  134. *                 INCXR
  135. *                 INCYR
  136. *                 CPY      #,5
  137. *                 BNE      LOOP
  138. *                 .
  139. *                 .
  140. *                 INCLUDE  RAMSBR.INI
  141. *        TABLE    FCB      1,2,3,4,5
  142. *        ADJUST   FDB      150
  143. *        COST     FDB      859
  144. *                 .
  145. *                 .
  146. *                 END
  147. *
  148. *    10. To assemble, use the following sample invocation lines:
  149. *          pasm05 -eq -l filename.lst filename.s    (debug= expanded)
  150. *            or
  151. *          pasm05 -bf -l filename.lst filename.s    (black box)
  152. *    11. Notations used by PASM05 are as follows:
  153. *          OPERATORS:  Special two character operators used are...
  154. *                        1. Logical AND                       !.
  155. *                        2. Shift Right (0 fill on left)      !>
  156. *          MACROS:     Special notations used are...
  157. *                        1. Parameters are positionally named using \0,
  158. *                           \1, \2, etc.
  159. *                        2. Labels within macros are designated via \.a,
  160. *                           where "a" is an alphanumeric character.  The
  161. *                           assembler generates a unique label to avoid
  162. *                           multiply defined label problems.
  163. *    12. Some macros access 16-bit values as LS byte then MS byte in order
  164. *        to be more efficient for condition code (CC) setting.  This is
  165. *        the reverse order that the 68HC11 would access the two byte
  166. *        halves.  This difference would only be a concern in accessing
  167. *        hardware registers, as normal RAM makes no difference.  Those
  168. *        macros with this difference have an entry in their Notes section.
  169. *    13. The latest version of this file is maintained on the Motorola
  170. *        FREEWARE Bulletin Board, 512/891-FREE (512/891-3733).  It operates
  171. *        continuously (except for maintenance) at 1200-2400 baud, 8 bits,
  172. *        no parity.  Sample test files for PASM05 are also included.
  173. *        Download the archive file, MACROS05.ARC, to get all the files.
  174. *
  175. **************************************************************************
  176. *  REVISION HISTORY   (add new changes to top):
  177. *
  178. *  05/16/90  P.S. Gilmour
  179. *    1. Created for Application Note AN1055.
  180. **************************************************************************
  181. LO$MEM   EQU    $00C0-7         Low memory ($0000-00FF) storage (7 bytes)
  182.  
  183.          OPT    NOL
  184. **************************************************************************
  185. *  LDD   = load  DREG
  186. *      LDD    [#,]<address>
  187. *
  188. *  Examples:
  189. *     1. "LDD   #,START"         puts the value of symbol 'START' into
  190. *                                the DREG (=A,X).
  191. *     2. "LDD   START"           puts the contents of location 'START'
  192. *                                and 'START'+1 into the DREG (=A,X).
  193. *
  194. *  Register Usage:
  195. *     A,X = loaded with new value (DREG).
  196. *     CC  = reflects MS half (=A).
  197. *     All other registers preserved.
  198. *
  199. *  Notes:
  200. *    1. Byte access order is LS, then MS (reversed from 68HC11).
  201. *
  202. LDD    MACR
  203.    IFEQ    NARG-1
  204.          LDX     (\0)+1
  205.          LDA     (\0)
  206.          MEXIT
  207.    ENDC
  208.    IFEQ    NARG-2
  209.      IFC     '\0','#'
  210.        IFEQ    (\1)!.$FF
  211.          CLRX
  212.        ENDC
  213.        IFNE    (\1)!.$FF
  214.          LDX     #(\1)!.$FF
  215.        ENDC
  216.        IFEQ    (\1)!>8
  217.          CLRA
  218.        ENDC
  219.        IFNE    (\1)!>8
  220.          LDA     #(\1)!>8
  221.        ENDC
  222.          MEXIT
  223.      ENDC
  224.    ENDC
  225.          FAIL    Macro syntax error detected!
  226.        ENDM
  227.  
  228. **************************************************************************
  229. *  STD   = store DREG
  230. *      STD    <address>
  231. *
  232. *  Examples:
  233. *     1. "STD   START"           stores the DREG (=A,X) into locations
  234. *                                'START' and 'START'+1.
  235. *
  236. *  Register Usage:
  237. *     CC  = reflects MS half (=A).
  238. *     All other registers preserved.
  239. *
  240. *  Notes:
  241. *    1. Byte access order is LS, then MS (reversed from 68HC11).
  242. *
  243. STD    MACR
  244.          STX     (\0)+1
  245.          STA     (\0)
  246.        ENDM
  247.  
  248. **************************************************************************
  249. *  ADDD  = add   DREG
  250. *      ADDD   [#,]<address>
  251. *
  252. *  Examples:
  253. *     1. "ADDD  #,START"         adds the value of symbol 'START' to the
  254. *                                DREG (=A,X).
  255. *     2. "ADDD  START"           adds the contents of location 'START'
  256. *                                and 'START'+1 to the DREG (=A,X).
  257. *
  258. *  Register Usage:
  259. *     A,X = contains new value (DREG).
  260. *     CC  = reflects MS half (=A).
  261. *     All other registers preserved.
  262. *
  263. ADDD   MACR
  264.    IFEQ    NARG-1
  265.          STA     TEMPA$
  266.          TXA
  267.          ADD     (\0)+1
  268.          TAX
  269.          LDA     TEMPA$
  270.          ADC     (\0)
  271.          MEXIT
  272.    ENDC
  273.    IFEQ    NARG-2
  274.      IFC     '\0','#'
  275.          STA     TEMPA$
  276.          TXA
  277.          ADD     #(\1)!.$FF
  278.          TAX
  279.          LDA     TEMPA$
  280.          ADC     #(\1)!>8
  281.          MEXIT
  282.      ENDC
  283.    ENDC
  284.          FAIL    Macro syntax error detected!
  285.        ENDM
  286.  
  287. **************************************************************************
  288. *  SUBD  = add   DREG
  289. *      SUBD   [#,]<address>
  290. *
  291. *  Examples:
  292. *     1. "SUBD  #,START"         subtracts the value of symbol 'START' from
  293. *                                the DREG (=A,X).
  294. *     2. "SUBD  START"           subtracts the contents of location 'START'
  295. *                                and 'START'+1 from the DREG (=A,X).
  296. *
  297. *  Register Usage:
  298. *     A,X = contains new value (DREG).
  299. *     CC  = reflects MS half (=A).
  300. *     All other registers preserved.
  301. *
  302. SUBD   MACR
  303.    IFEQ    NARG-1
  304.          STA     TEMPA$
  305.          TXA
  306.          SUB     (\0)+1
  307.          TAX
  308.          LDA     TEMPA$
  309.          SBC     (\0)
  310.          MEXIT
  311.    ENDC
  312.    IFEQ    NARG-2
  313.      IFC     '\0','#'
  314.          STA     TEMPA$
  315.          TXA
  316.          SUB     #(\1)!.$FF
  317.          TAX
  318.          LDA     TEMPA$
  319.          SBC     #(\1)!>8
  320.          MEXIT
  321.      ENDC
  322.    ENDC
  323.          FAIL    Macro syntax error detected!
  324.        ENDM
  325.  
  326. **************************************************************************
  327. *  CPD   = compare DREG
  328. *      CPD    [#,]<address>
  329. *
  330. *  Examples:
  331. *     1. "CPD   #,BLOCKSZ"       compares the value of symbol 'BLOCKSZ'
  332. *                                with the DREG (=A,X).
  333. *     2. "CPD   START"           compares the contents of location
  334. *                                'START' and 'START'+1 with the DREG.
  335. *
  336. *  Register Usage:
  337. *     CC  = reflects DREG comparison (Z-bit only).
  338. *     All other registers preserved.
  339. *
  340. CPD    MACR
  341.    IFEQ    NARG-1
  342.          CPX     (\0)+1
  343.          BNE     \.0
  344.          CMP     (\0)
  345. \.0      EQU     *
  346.          MEXIT
  347.    ENDC
  348.    IFEQ    NARG-2
  349.      IFC     '\0','#'
  350.        IFEQ    (\1)!.$FF
  351.          TSTX
  352.        ENDC
  353.        IFNE    (\1)!.$FF
  354.          CPX     #(\1)!.$FF
  355.        ENDC
  356.          BNE     \.0
  357.        IFEQ    (\1)!>8
  358.          TSTA
  359.        ENDC
  360.        IFNE    (\1)!>8
  361.          CMP     #(\1)!>8
  362.        ENDC
  363. \.0      EQU     *
  364.          MEXIT
  365.      ENDC
  366.    ENDC
  367.          FAIL    Macro syntax error detected!
  368.        ENDM
  369.  
  370. **************************************************************************
  371. *  LDAXY = load A via 16-bit pseudo-register (XREG or YREG)
  372. *      LDAXY  <offset>,XREG
  373. *      LDAXY  <offset>,YREG
  374. *
  375. *  Examples:
  376. *     1. "LDAXY  0,XREG"         loads the contents of the memory location
  377. *                                specified by XREG+0 into the A accumulator.
  378. *     2. "LDAXY  ,XREG"          loads the contents of the memory location
  379. *                                specified by XREG+0 into the accumulator.
  380. *     3. "LDAXY  TBL,XREG"       loads the contents of the memory location
  381. *                                specified by XREG+'TBL' into the A accum-
  382. *                                ulator.
  383. *     4. Above examples can be repeated with substituting YREG for XREG.
  384. *
  385. *  Register Usage:
  386. *     A   = loaded with new value.
  387. *     DREG= destroyed.
  388. *     CC  = reflects value loaded.
  389. *     All other registers preserved.
  390. *
  391. LDAXY  MACR
  392.    IFNC    '\1','XREG'
  393.      IFNC    '\1','YREG'
  394.          FAIL    Macro syntax error detected!
  395.          MEXIT
  396.      ENDC
  397.    ENDC
  398.    IFC     '\0',''
  399.          JSR     LDA\1       Default offset= 0
  400.          MEXIT
  401.    ENDC
  402.    IFNC    '\0',''
  403.      IFEQ    \0
  404.          JSR     LDA\1       Offset= 0
  405.          MEXIT
  406.      ENDC
  407.      IFNE    \0
  408.          LDA     \11$+1      Set nREG= offset + nREG
  409.          ADD     #(\0)!.$FF
  410.          STA     \11$+1
  411.          LDA     \11$
  412.          ADC     #(\0)!>8
  413.          STA     \11$
  414.          JSR     LDA\1       Offset= 0
  415.          STA     TEMPA$
  416.          LDA     \12$        Restore nREG
  417.          STA     \11$
  418.          LDA     \12$+1
  419.          STA     \11$+1
  420.          LDA     TEMPA$
  421.          MEXIT
  422.      ENDC
  423.    ENDC
  424.          FAIL    Macro syntax error detected!
  425.        ENDM
  426.  
  427. **************************************************************************
  428. *  STAXY = store A via 16-bit pseudo-register (XREG or YREG)
  429. *      STAXY  <offset>,XREG
  430. *      STAXY  <offset>,YREG
  431. *
  432. *  Examples:
  433. *     1. "STAXY  0,XREG"         stores the accumulator (=A) into the memory
  434. *                                location specified by XREG+0.
  435. *     2. "STAXY  ,XREG"          stores the accumulator (=A) into the memory
  436. *                                location specified by XREG+0.
  437. *     3. "STAXY  TBL,XREG"       stores the accumulator (=A) into the memory
  438. *                                specified by XREG+'TBL'.
  439. *     4. Above examples can be repeated with substituting YREG for XREG.
  440. *
  441. *  Register Usage:
  442. *     CC = reflects value stored.
  443. *     All other registers preserved.
  444. *
  445. STAXY  MACR
  446.    IFNC    '\1','XREG'
  447.      IFNC    '\1','YREG'
  448.          FAIL    Macro syntax error detected!
  449.          MEXIT
  450.      ENDC
  451.    ENDC
  452.    IFC     '\0',''
  453.          JSR     STA\1       Default offset= 0
  454.          MEXIT
  455.    ENDC
  456.    IFNC    '\0',''
  457.      IFEQ    \0
  458.          JSR     STA\1       Offset= 0
  459.          MEXIT
  460.      ENDC
  461.      IFNE    \0
  462.          STA     TEMPA$
  463.          LDA     \12$+1      Set nREG= offset + nREG
  464.          ADD     #(\0)!.$FF
  465.          STA     \12$+1
  466.          LDA     \12$
  467.          ADC     #(\0)!>8
  468.          STA     \12$
  469.          LDA     TEMPA$
  470.          JSR     STA\1       Offset= 0
  471.          LDA     \11$        Restore nREG
  472.          STA     \12$
  473.          LDA     \11$+1
  474.          STA     \12$+1
  475.          LDA     TEMPA$
  476.          MEXIT
  477.      ENDC
  478.    ENDC
  479.          FAIL    Macro syntax error detected!
  480.        ENDM
  481.  
  482. **************************************************************************
  483. *  LDXR  = load  XREG
  484. *      LDXR   [#,]<address>
  485. *
  486. *  Examples:
  487. *     1. "LDXR  #,START"         puts the value of symbol 'START' into the
  488. *                                XREG.
  489. *     2. "LDXR  START"           puts the contents of location 'START' and
  490. *                                'START'+1 into the XREG.
  491. *
  492. *  Register Usage:
  493. *     CC = reflects MS half (=A).
  494. *     All other registers preserved.
  495. *
  496. *  Notes:
  497. *    1. Byte access order is LS, then MS (reversed from 68HC11).
  498. *
  499. LDXR   MACR
  500.    IFEQ    NARG-1
  501.          STA     TEMPA$
  502.          LDA     (\0)+1
  503.          STA     XREG1$+1
  504.          STA     XREG2$+1
  505.          LDA     (\0)
  506.          STA     XREG1$
  507.          STA     XREG2$
  508.      IFEQ    XREG1$!.$FF00
  509.          LDA     TEMPA$
  510.          TST     XREG1$
  511.      ENDC
  512.      IFNE    XREG1$!.$FF00
  513.          STA     TESTA$
  514.          LDA     TEMPA$
  515.          TST     TESTA$
  516.      ENDC
  517.          MEXIT
  518.    ENDC
  519.    IFEQ    NARG-2
  520.      IFC     '\0','#'
  521.        IFEQ    XREG1$!.$FF00     ! XREG in low memory?
  522.          IFEQ    \1              !   #0 value?
  523.            CLR     XREG1$+1
  524.            CLR     XREG2$+1
  525.            CLR     XREG1$
  526.            CLR     XREG2$
  527.            MEXIT
  528.          ENDC
  529.          IFNE    \1              !   not #0 value?
  530.              STA     TEMPA$
  531.            IFEQ    (\1)!.$FF
  532.              CLR     XREG1$+1
  533.              CLR     XREG2$+1
  534.            ENDC
  535.            IFNE    (\1)!.$FF
  536.              LDA     #(\1)!.$FF
  537.              STA     XREG1$+1
  538.              STA     XREG2$+1
  539.            ENDC
  540.            IFEQ    (\1)!>8
  541.              CLR     XREG1$
  542.              CLR     XREG2$
  543.            ENDC
  544.            IFNE    (\1)!>8
  545.              LDA     #(\1)!>8
  546.              STA     XREG1$
  547.              STA     XREG2$
  548.            ENDC
  549.              LDA     TEMPA$
  550.              TST     XREG1$
  551.              MEXIT
  552.          ENDC
  553.        ENDC
  554.        IFNE    XREG1$!.$FF00     ! XREG in high memory?
  555.          IFEQ    \1              !   #0 value?
  556.            STA     TEMPA$
  557.            CLRA
  558.            STA     XREG1$+1
  559.            STA     XREG2$+1
  560.            STA     XREG1$
  561.            STA     XREG2$
  562.            CLR     TESTA$
  563.            LDA     TEMPA$
  564.            TST     TESTA$
  565.            MEXIT
  566.          ENDC
  567.          IFNE    \1              !   not #0 value?
  568.              STA     TEMPA$
  569.            IFEQ    (\1)!.$FF
  570.              CLRA
  571.            ENDC
  572.            IFNE    (\1)!.$FF
  573.              LDA     #(\1)!.$FF
  574.            ENDC
  575.              STA     XREG1$+1
  576.              STA     XREG2$+1
  577.            IFEQ    (\1)!>8
  578.              CLRA
  579.            ENDC
  580.            IFNE    (\1)!>8
  581.              LDA     #(\1)!>8
  582.            ENDC
  583.              STA     XREG1$
  584.              STA     XREG2$
  585.              STA     TESTA$
  586.              LDA     TEMPA$
  587.              TST     TESTA$
  588.              MEXIT
  589.          ENDC
  590.        ENDC
  591.      ENDC
  592.    ENDC
  593.          FAIL    Macro syntax error detected!
  594.        ENDM
  595.  
  596. **************************************************************************
  597. *  STXR  = store  XREG
  598. *      STXR   <address>
  599. *
  600. *  Examples:
  601. *     1. "STXR  START"           stores the XREG into locations 'START' and
  602. *                                'START'+1.
  603. *
  604. *  Register Usage:
  605. *     CC = reflects MS half (=A).
  606. *     All other registers preserved.
  607. *
  608. *  Notes:
  609. *    1. Byte access order is LS, then MS (reversed from 68HC11).
  610. *
  611. STXR   MACR
  612.          STA     TEMPA$
  613.          LDA     XREG1$+1
  614.          STA     (\0)+1
  615.          LDA     XREG1$
  616.          STA     (\0)
  617.      IFEQ    XREG1$!.$FF00
  618.          LDA     TEMPA$
  619.          TST     XREG1$
  620.      ENDC
  621.      IFNE    XREG1$!.$FF00
  622.          STA     TESTA$
  623.          LDA     TEMPA$
  624.          TST     TESTA$
  625.      ENDC
  626.        ENDM
  627.  
  628. **************************************************************************
  629. *  INCXR = increment XREG
  630. *      INCXR  [[#,]<address>]
  631. *
  632. *  Examples:
  633. *     1. "INCXR"                 adds one (1) to the XREG.
  634. *     2. "INCXR  #,START"        adds the value of symbol 'START' to the
  635. *                                XREG.
  636. *     3. "INCXR  START"          adds the contents of location 'START' and
  637. *                                'START'+1 to the XREG.
  638. *     4. "INCXR    ! comment"    adds one (1) to the XREG (comment present!).
  639. *
  640. *  Register Usage:
  641. *     CC = reflects value incremented (Z-bit only).
  642. *     All other registers preserved.
  643. *
  644. *  Notes:
  645. *    1. Explicit comment character (!) MUST be used when comment field is
  646. *       present to prevent confusion with parameters!
  647. *    2. Assumes XREG1$ = XREG2$.
  648. *    3. When parameters are present, this macro becomes "ADD to XREG".
  649. *
  650. INCXR  MACR
  651.    IFEQ    NARG
  652.      IFEQ    XREG1$!.$FF00
  653.          INC     XREG1$+1
  654.          INC     XREG2$+1
  655.          BNE     \.0
  656.          INC     XREG1$
  657.          INC     XREG2$
  658. \.0      EQU     *
  659.          MEXIT
  660.      ENDC
  661.      IFNE    XREG1$!.$FF00
  662.          STA     TEMPA$
  663.          LDA     XREG1$+1
  664.          ADD     #1
  665.          STA     XREG1$+1
  666.          STA     XREG2$+1
  667.          LDA     XREG1$
  668.          ADC     #0
  669.          STA     XREG1$
  670.          STA     XREG2$
  671.          ORA     XREG1$+1
  672.          STA     TESTA$
  673.          LDA     TEMPA$
  674.          TST     TESTA$
  675.          MEXIT
  676.      ENDC
  677.    ENDC
  678.    IFEQ    NARG-1
  679.          STA     TEMPA$
  680.          LDA     XREG1$+1
  681.          ADD     (\0)+1
  682.          STA     XREG1$+1
  683.          STA     XREG2$+1
  684.          LDA     XREG1$
  685.          ADC     \0
  686.          STA     XREG1$
  687.          STA     XREG2$
  688.          ORA     XREG1$+1
  689.          STA     TESTA$
  690.          LDA     TEMPA$
  691.          TST     TESTA$
  692.          MEXIT
  693.    ENDC
  694.    IFEQ    NARG-2
  695.      IFC     '\0','#'
  696.          STA     TEMPA$
  697.          LDA     XREG1$+1
  698.          ADD     #(\1)!.$FF
  699.          STA     XREG1$+1
  700.          STA     XREG2$+1
  701.          LDA     XREG1$
  702.          ADC     #(\1)!>8
  703.          STA     XREG1$
  704.          STA     XREG2$
  705.          ORA     XREG1$+1
  706.          STA     TESTA$
  707.          LDA     TEMPA$
  708.          TST     TESTA$
  709.          MEXIT
  710.      ENDC
  711.    ENDC
  712.          FAIL    Macro syntax error detected!
  713.        ENDM
  714.  
  715. **************************************************************************
  716. *  DECXR = decrement XREG
  717. *      DECXR  [[#,]<address>]
  718. *
  719. *  Examples:
  720. *     1. "DECXR"                 subtracts one (1) from the XREG.
  721. *     2. "DECXR  #,START"        subtracts the value of symbol 'START' from
  722. *                                the XREG.
  723. *     3. "DECXR  START"          subtracts the contents of location 'START'
  724. *                                and 'START'+1 from the XREG.
  725. *     4. "DECXR    ! comment"    subtracts one from the XREG (comment present!).
  726. *
  727. *  Register Usage:
  728. *     CC = reflects value decremented (Z-bit only).
  729. *     All other registers preserved.
  730. *
  731. *  Notes:
  732. *    1. Explicit comment character (!) MUST be used when comment field is
  733. *       present!
  734. *    2. Assumes XREG1$ = XREG2$.
  735. *    3. When parameters are present, this macro becomes "SUBTRACT from XREG".
  736. *
  737. DECXR  MACR
  738.    IFEQ    NARG
  739.          STA     TEMPA$
  740.          LDA     XREG1$+1
  741.          SUB     #1
  742.          STA     XREG1$+1
  743.          STA     XREG2$+1
  744.          LDA     XREG1$
  745.          SBC     #0
  746.          STA     XREG1$
  747.          STA     XREG2$
  748.          ORA     XREG1$+1
  749.          STA     TESTA$
  750.          LDA     TEMPA$
  751.          TST     TESTA$
  752.          MEXIT
  753.    ENDC
  754.    IFEQ    NARG-1
  755.          STA     TEMPA$
  756.          LDA     XREG1$+1
  757.          SUB     (\0)+1
  758.          STA     XREG1$+1
  759.          STA     XREG2$+1
  760.          LDA     XREG1$
  761.          SBC     \0
  762.          STA     XREG1$
  763.          STA     XREG2$
  764.          ORA     XREG1$+1
  765.          STA     TESTA$
  766.          LDA     TEMPA$
  767.          TST     TESTA$
  768.          MEXIT
  769.    ENDC
  770.    IFEQ    NARG-2
  771.      IFC     '\0','#'
  772.          STA     TEMPA$
  773.          LDA     XREG1$+1
  774.          SUB     #(\1)!.$FF
  775.          STA     XREG1$+1
  776.          STA     XREG2$+1
  777.          LDA     XREG1$
  778.          SBC     #(\1)!>8
  779.          STA     XREG1$
  780.          STA     XREG2$
  781.          ORA     XREG1$+1
  782.          STA     TESTA$
  783.          LDA     TEMPA$
  784.          TST     TESTA$
  785.          MEXIT
  786.      ENDC
  787.    ENDC
  788.          FAIL    Macro syntax error detected!
  789.        ENDM
  790.  
  791. **************************************************************************
  792. *  CPXR  = compare XREG
  793. *      CPXR   [#,]<address>
  794. *
  795. *  Examples:
  796. *     1. "CPXR  #,BLOCKSZ"       compares the value of symbol 'BLOCKSZ'
  797. *                                with the XREG.
  798. *     2. "CPXR  START"           compares the contents of location
  799. *                                'START' and 'START'+1 with the XREG.
  800. *
  801. *  Register Usage:
  802. *     CC  = reflects XREG comparison (Z-bit only).
  803. *     All other registers preserved.
  804. *
  805. CPXR   MACR
  806.    IFEQ    NARG-1
  807.          STA     TEMPA$
  808.          BSET    0,TESTA$   Preset for .NE. condition!
  809.          LDA     XREG1$+1
  810.          CMP     (\0)+1
  811.          BNE     \.0        Branch if LS half is .NE.
  812.          LDA     XREG1$
  813.          CMP     (\0)
  814.          BNE     \.0        Branch if MS half is .NE.
  815.          CLR     TESTA$     Set for .EQ. condition!
  816. \.0      LDA     TEMPA$
  817.          TST     TESTA$     Set proper Z-bit (.EQ. or .NE.)!
  818.          MEXIT
  819.    ENDC
  820.    IFEQ    NARG-2
  821.      IFC     '\0','#'
  822.        IFEQ    \1
  823.          IFEQ    XREG1$!.$FF00
  824.            TST     XREG1$+1
  825.            BNE     \.0        Branch if LS half is .NE.
  826.            TST     XREG1$
  827. \.0        EQU     *
  828.            MEXIT
  829.          ENDC
  830.          IFNE    XREG1$!.$FF00
  831.            STA     TEMPA$
  832.            BSET    0,TESTA$   Preset for .NE. condition!
  833.            LDA     XREG1$+1
  834.            BNE     \.0        Branch if MS half is .NE.
  835.            LDA     XREG1$
  836.            BNE     \.0        Branch if MS half is .NE.
  837.            CLR     TESTA$     Set for .EQ. condition!
  838. \.0        LDA     TEMPA$
  839.            TST     TESTA$     Set proper Z-bit (.EQ. or .NE.)!
  840.            MEXIT
  841.          ENDC
  842.        ENDC
  843.          STA     TEMPA$
  844.          BSET    0,TESTA$   Preset for .NE. condition!
  845.          LDA     XREG1$+1
  846.        IFNE    (\1)!.$FF
  847.          CMP     #(\1)!.$FF
  848.        ENDC
  849.          BNE     \.0        Branch if LS half is .NE.
  850.          LDA     XREG1$
  851.        IFNE    (\1)!>8
  852.          CMP     #(\1)!>8
  853.        ENDC
  854.          BNE     \.0        Branch if MS half is .NE.
  855.          CLR     TESTA$     Set for .EQ. condition!
  856. \.0      LDA     TEMPA$
  857.          TST     TESTA$     Set proper Z-bit (.EQ. or .NE.)!
  858.          MEXIT
  859.      ENDC
  860.    ENDC
  861.          FAIL    Macro syntax error detected!
  862.        ENDM
  863.  
  864. **************************************************************************
  865. *  LDYR  = load  YREG
  866. *      LDYR   [#,]<address>
  867. *
  868. *  Examples:
  869. *     1. "LDYR  #,START"         puts the value of symbol 'START' into the
  870. *                                YREG.
  871. *     2. "LDYR  START"           puts the contents of location 'START' and
  872. *                                'START'+1 into the YREG.
  873. *
  874. *  Register Usage:
  875. *     CC = reflects MS half.
  876. *     All other registers preserved.
  877. *
  878. LDYR   MACR
  879.    IFEQ    NARG-1
  880.          STA     TEMPA$
  881.          LDA     (\0)
  882.          STA     YREG1$
  883.          STA     YREG2$
  884.          LDA     (\0)+1
  885.          STA     YREG1$+1
  886.          STA     YREG2$+1
  887.      IFEQ    YREG1$!.$FF00
  888.          LDA     TEMPA$
  889.          TST     YREG1$
  890.      ENDC
  891.      IFNE    YREG1$!.$FF00
  892.          STA     TESTA$
  893.          LDA     TEMPA$
  894.          TST     TESTA$
  895.      ENDC
  896.          MEXIT
  897.    ENDC
  898.    IFEQ    NARG-2
  899.      IFC     '\0','#'
  900.        IFEQ    YREG1$!.$FF00     ! YREG in low memory?
  901.          IFEQ    \1              !   #0 value?
  902.            CLR     YREG1$+1
  903.            CLR     YREG2$+1
  904.            CLR     YREG1$
  905.            CLR     YREG2$
  906.            MEXIT
  907.          ENDC
  908.          IFNE    \1              !   not #0 value?
  909.              STA     TEMPA$
  910.            IFEQ    (\1)!.$FF
  911.              CLR     YREG1$+1
  912.              CLR     YREG2$+1
  913.            ENDC
  914.            IFNE    (\1)!.$FF
  915.              LDA     #(\1)!.$FF
  916.              STA     YREG1$+1
  917.              STA     YREG2$+1
  918.            ENDC
  919.            IFEQ    (\1)!>8
  920.              CLR     YREG1$
  921.              CLR     YREG2$
  922.            ENDC
  923.            IFNE    (\1)!>8
  924.              LDA     #(\1)!>8
  925.              STA     YREG1$
  926.              STA     YREG2$
  927.            ENDC
  928.              LDA     TEMPA$
  929.              TST     YREG1$
  930.              MEXIT
  931.          ENDC
  932.        ENDC
  933.        IFNE    YREG1$!.$FF00     ! YREG in high memory?
  934.          IFEQ    \1              !   #0 value?
  935.            STA     TEMPA$
  936.            CLRA
  937.            STA     YREG1$+1
  938.            STA     YREG2$+1
  939.            STA     YREG1$
  940.            STA     YREG2$
  941.            CLR     TESTA$
  942.            LDA     TEMPA$
  943.            TST     TESTA$
  944.            MEXIT
  945.          ENDC
  946.          IFNE    \1              !   not #0 value?
  947.              STA     TEMPA$
  948.            IFEQ    (\1)!.$FF
  949.              CLRA
  950.            ENDC
  951.            IFNE    (\1)!.$FF
  952.              LDA     #(\1)!.$FF
  953.            ENDC
  954.              STA     YREG1$+1
  955.              STA     YREG2$+1
  956.            IFEQ    (\1)!>8
  957.              CLRA
  958.            ENDC
  959.            IFNE    (\1)!>8
  960.              LDA     #(\1)!>8
  961.            ENDC
  962.              STA     YREG1$
  963.              STA     YREG2$
  964.              STA     TESTA$
  965.              LDA     TEMPA$
  966.              TST     TESTA$
  967.              MEXIT
  968.          ENDC
  969.        ENDC
  970.      ENDC
  971.    ENDC
  972.          FAIL    Macro syntax error detected!
  973.        ENDM
  974.  
  975. **************************************************************************
  976. *  STYR  = store  YREG
  977. *      STYR   <address>
  978. *
  979. *  Examples:
  980. *     1. "STYR  START"           stores the YREG into locations 'START' and
  981. *                                'START'+1.
  982. *
  983. *  Register Usage:
  984. *     CC = reflects MS half.
  985. *     All other registers preserved.
  986. *
  987. STYR   MACR
  988.          STA     TEMPA$
  989.          LDA     YREG1$
  990.          STA     (\0)
  991.          LDA     YREG1$+1
  992.          STA     (\0)+1
  993.      IFEQ    YREG1$!.$FF00
  994.          LDA     TEMPA$
  995.          TST     YREG1$
  996.      ENDC
  997.      IFNE    YREG1$!.$FF00
  998.          STA     TESTA$
  999.          LDA     TEMPA$
  1000.          TST     TESTA$
  1001.      ENDC
  1002.        ENDM
  1003.  
  1004. **************************************************************************
  1005. *  INCYR = increment YREG
  1006. *      INCYR  [[#,]<value>]
  1007. *
  1008. *  Examples:
  1009. *     1. "INCYR"                 adds one (1) to the YREG.
  1010. *     2. "INCYR  #,START"        adds the value of symbol 'START' to the
  1011. *                                YREG.
  1012. *     3. "INCYR  START"          adds the contents of location 'START' and
  1013. *                                'START'+1 to the YREG.
  1014. *     4. "INCYR    ! comment"    adds one (1) to the YREG (comment present!).
  1015. *
  1016. *  Register Usage:
  1017. *     CC = reflects value incremented (Z-bit only).
  1018. *     All other registers preserved.
  1019. *
  1020. *  Notes:
  1021. *    1. Explicit comment character (!) MUST be used when comment field is
  1022. *       present!
  1023. *    2. Assumes YREG1$ = YREG2$.
  1024. *    3. When parameters are present, this macro becomes "ADD to YREG".
  1025. *
  1026. INCYR  MACR
  1027.    IFEQ    NARG
  1028.      IFEQ    YREG1$!.$FF00
  1029.          INC     YREG1$+1
  1030.          INC     YREG2$+1
  1031.          BNE     \.0
  1032.          INC     YREG1$
  1033.          INC     YREG2$
  1034. \.0      EQU     *
  1035.          MEXIT
  1036.      ENDC
  1037.      IFNE    YREG1$!.$FF00
  1038.          STA     TEMPA$
  1039.          LDA     YREG1$+1
  1040.          ADD     #1
  1041.          STA     YREG1$+1
  1042.          STA     YREG2$+1
  1043.          LDA     YREG1$
  1044.          ADC     #0
  1045.          STA     YREG1$
  1046.          STA     YREG2$
  1047.          ORA     YREG1$+1
  1048.          STA     TESTA$
  1049.          LDA     TEMPA$
  1050.          TST     TESTA$
  1051.          MEXIT
  1052.      ENDC
  1053.    ENDC
  1054.    IFEQ    NARG-1
  1055.          STA     TEMPA$
  1056.          LDA     YREG1$+1
  1057.          ADD     (\0)+1
  1058.          STA     YREG1$+1
  1059.          STA     YREG2$+1
  1060.          LDA     YREG1$
  1061.          ADC     \0
  1062.          STA     YREG1$
  1063.          STA     YREG2$
  1064.          ORA     YREG1$+1
  1065.          STA     TESTA$
  1066.          LDA     TEMPA$
  1067.          TST     TESTA$
  1068.          MEXIT
  1069.    ENDC
  1070.    IFEQ    NARG-2
  1071.      IFC     '\0','#'
  1072.          STA     TEMPA$
  1073.          LDA     YREG1$+1
  1074.          ADD     #(\1)!.$FF
  1075.          STA     YREG1$+1
  1076.          STA     YREG2$+1
  1077.          LDA     YREG1$
  1078.          ADC     #(\1)!>8
  1079.          STA     YREG1$
  1080.          STA     YREG2$
  1081.          ORA     XREG1$+1
  1082.          STA     TESTA$
  1083.          LDA     TEMPA$
  1084.          TST     TESTA$
  1085.          MEXIT
  1086.      ENDC
  1087.    ENDC
  1088.          FAIL    Macro syntax error detected!
  1089.        ENDM
  1090.  
  1091. **************************************************************************
  1092. *  DECYR = decrement YREG
  1093. *      DECYR  [[#,]<value>]
  1094. *
  1095. *  Examples:
  1096. *     1. "DECYR"                 subtracts one (1) from the YREG.
  1097. *     2. "DECYR  #,START"        subtracts the value of symbol 'START' from
  1098. *                                the YREG.
  1099. *     3. "DECYR  START"          subtracts the contents of location 'START'
  1100. *                                and 'START'+1 from the YREG.
  1101. *     4. "DECYR    ! comment"    subtracts one from the YREG (comment present!).
  1102. *
  1103. *  Register Usage:
  1104. *     CC = reflects value decremented (Z-bit only).
  1105. *     All other registers preserved.
  1106. *
  1107. *  Notes:
  1108. *    1. Explicit comment character (!) MUST be used when comment field is
  1109. *       present!
  1110. *    2. Assumes YREG1$ = YREG2$.
  1111. *    3. When parameters are present, this macro becomes "SUBTRACT from YREG".
  1112. *
  1113. DECYR  MACR
  1114.    IFEQ    NARG
  1115.          STA     TEMPA$
  1116.          LDA     YREG1$+1
  1117.          SUB     #1
  1118.          STA     YREG1$+1
  1119.          STA     YREG2$+1
  1120.          LDA     YREG1$
  1121.          SBC     #0
  1122.          STA     YREG1$
  1123.          STA     YREG2$
  1124.          ORA     YREG1$+1
  1125.          STA     TESTA$
  1126.          LDA     TEMPA$
  1127.          TST     TESTA$
  1128.          MEXIT
  1129.    ENDC
  1130.    IFEQ    NARG-1
  1131.          STA     TEMPA$
  1132.          LDA     YREG1$+1
  1133.          SUB     (\0)+1
  1134.          STA     YREG1$+1
  1135.          STA     YREG2$+1
  1136.          LDA     YREG1$
  1137.          SBC     \0
  1138.          STA     YREG1$
  1139.          STA     YREG2$
  1140.          ORA     YREG1$+1
  1141.          STA     TESTA$
  1142.          LDA     TEMPA$
  1143.          TST     TESTA$
  1144.          MEXIT
  1145.    ENDC
  1146.    IFEQ    NARG-2
  1147.      IFC     '\0','#'
  1148.          STA     TEMPA$
  1149.          LDA     YREG1$+1
  1150.          SUB     #(\1)!.$FF
  1151.          STA     YREG1$+1
  1152.          STA     YREG2$+1
  1153.          LDA     YREG1$
  1154.          SBC     #(\1)!>8
  1155.          STA     YREG1$
  1156.          STA     YREG2$
  1157.          ORA     YREG1$+1
  1158.          STA     TESTA$
  1159.          LDA     TEMPA$
  1160.          TST     TESTA$
  1161.          MEXIT
  1162.      ENDC
  1163.    ENDC
  1164.          FAIL    Macro syntax error detected!
  1165.        ENDM
  1166.  
  1167. **************************************************************************
  1168. *  CPYR  = compare YREG
  1169. *      CPYR   [#,]<address>
  1170. *
  1171. *  Examples:
  1172. *     1. "CPYR  #,BLOCKSZ"       compares the value of symbol 'BLOCKSZ'
  1173. *                                with the YREG.
  1174. *     2. "CPYR  START"           compares the contents of location
  1175. *                                'START' and 'START'+1 with the YREG.
  1176. *
  1177. *  Register Usage:
  1178. *     CC  = reflects YREG comparison (Z-bit only).
  1179. *     All other registers preserved.
  1180. *
  1181. CPYR   MACR
  1182.    IFEQ    NARG-1
  1183.          STA     TEMPA$
  1184.          BSET    0,TESTA$   Preset for .NE. condition!
  1185.          LDA     YREG1$+1
  1186.          CMP     (\0)+1
  1187.          BNE     \.0        Branch if LS half is .NE.
  1188.          LDA     YREG1$
  1189.          CMP     (\0)
  1190.          BNE     \.0        Branch if MS half is .NE.
  1191.          CLR     TESTA$     Set for .EQ. condition!
  1192. \.0      LDA     TEMPA$
  1193.          TST     TESTA$     Set proper Z-bit (.EQ. or .NE.)!
  1194.          MEXIT
  1195.    ENDC
  1196.    IFEQ    NARG-2
  1197.      IFC     '\0','#'
  1198.        IFEQ    \1
  1199.          IFEQ    YREG1$!.$FF00
  1200.            TST     YREG1$+1
  1201.            BNE     \.0        Branch if LS half is .NE.
  1202.            TST     YREG1$
  1203. \.0        EQU     *
  1204.            MEXIT
  1205.          ENDC
  1206.          IFNE    YREG1$!.$FF00
  1207.            STA     TEMPA$
  1208.            BSET    0,TESTA$   Preset for .NE. condition!
  1209.            LDA     YREG1$+1
  1210.            BNE     \.0        Branch if MS half is .NE.
  1211.            LDA     YREG1$
  1212.            BNE     \.0        Branch if MS half is .NE.
  1213.            CLR     TESTA$     Set for .EQ. condition!
  1214. \.0        LDA     TEMPA$
  1215.            TST     TESTA$     Set proper Z-bit (.EQ. or .NE.)!
  1216.            MEXIT
  1217.          ENDC
  1218.        ENDC
  1219.          STA     TEMPA$
  1220.          BSET    0,TESTA$   Preset for .NE. condition!
  1221.          LDA     YREG1$+1
  1222.        IFNE    (\1)!.$FF
  1223.          CMP     #(\1)!.$FF
  1224.        ENDC
  1225.          BNE     \.0        Branch if LS half is .NE.
  1226.          LDA     YREG1$
  1227.        IFNE    (\1)!>8
  1228.          CMP     #(\1)!>8
  1229.        ENDC
  1230.          BNE     \.0        Branch if MS half is .NE.
  1231.          CLR     TESTA$     Set for .EQ. condition!
  1232. \.0      LDA     TEMPA$
  1233.          TST     TESTA$     Set proper Z-bit (.EQ. or .NE.)!
  1234.          MEXIT
  1235.      ENDC
  1236.    ENDC
  1237.          FAIL    Macro syntax error detected!
  1238.        ENDM
  1239.  
  1240. **************************************************************************
  1241. *  DEC.B = decrement byte
  1242. *      DEC.B  [[#,]<value>,]<address>
  1243. *
  1244. *  where:
  1245. *     <value>    = value to decrement the contents of the <address>
  1246. *                  location by; immediate ("#," present) or absolute
  1247. *                  addressing ("#," not present).  If only <address> is
  1248. *                  specified, a default immediate value of one is used.
  1249. *
  1250. *  Examples:
  1251. *     1. "DEC.B  START"          subtracts one from the contents of
  1252. *                                location 'START'.
  1253. *     2. "DEC.B  #,5,START"      subtracts five from the contents of
  1254. *                                location 'START'.
  1255. *     3. "DEC.B  CNT,START"      subtracts the contents of location 'CNT'
  1256. *                                from the contents of location 'START'.
  1257. *
  1258. *  Register Usage:
  1259. *     CC = reflects value decremented (N and Z-bits).
  1260. *     All other registers preserved.
  1261. *
  1262. *  Notes:
  1263. *    1. <address> may be direct or extended!
  1264. *    2. This macro essentially performs a "SUB n" function.
  1265. *
  1266. DEC.B  MACR
  1267.    IFEQ    NARG-1
  1268.      IFEQ    (\0)!.$FF00
  1269.          DEC     \0
  1270.          MEXIT
  1271.      ENDC
  1272.          STA     TEMPA$
  1273.          LDA     \0
  1274.          SUB     #1
  1275.          STA     \0
  1276.          STA     TESTA$
  1277.          LDA     TEMPA$
  1278.          TST     TESTA$
  1279.          MEXIT
  1280.    ENDC
  1281.    IFEQ    NARG-2
  1282.          STA     TEMPA$
  1283.          LDA     \1
  1284.          SUB     \0
  1285.          STA     \1
  1286.      IFEQ    (\1)!.$FF00
  1287.          LDA     TEMPA$
  1288.          TST     \1
  1289.          MEXIT
  1290.      ENDC
  1291.      IFNE    (\1)!.$FF00
  1292.          STA     TESTA$
  1293.          LDA     TEMPA$
  1294.          TST     TESTA$
  1295.          MEXIT
  1296.      ENDC
  1297.    ENDC
  1298.    IFEQ    NARG-3
  1299.      IFC     '\0','#'
  1300.          STA     TEMPA$
  1301.          LDA     \2
  1302.          SUB     #\1
  1303.          STA     \2
  1304.        IFEQ    (\2)!.$FF00
  1305.          LDA     TEMPA$
  1306.          TST     \2
  1307.          MEXIT
  1308.        ENDC
  1309.        IFNE    (\2)!.$FF00
  1310.          STA     TESTA$
  1311.          LDA     TEMPA$
  1312.          TST     TESTA$
  1313.          MEXIT
  1314.        ENDC
  1315.      ENDC
  1316.    ENDC
  1317.          FAIL    Macro syntax error detected!
  1318.        ENDM
  1319.  
  1320. **************************************************************************
  1321. *  DEC.W = decrement word
  1322. *      DEC.W  [[#,]<value>,]<address>
  1323. *
  1324. *  where:
  1325. *     <value>    = value to decrement the contents of the <address> and
  1326. *                  <address>+1 locations by; immediate ("#," present) or
  1327. *                  absolute addressing ("#," not present).  If only
  1328. *                  <address> is specified, a default immediate value of
  1329. *                  one is used.
  1330. *
  1331. *  Examples:
  1332. *     1. "DEC.W  START"          subtracts one from the contents of loca-
  1333. *                                tions 'START' and 'START'+1.
  1334. *     2. "DEC.W  CNT,START"      subtracts the contents of locations 'CNT'
  1335. *                                and 'CNT'+1 from the contents of locations
  1336. *                                'START' and 'START'+1.
  1337. *     3. "DEC.W  #,5,START"      subtracts five from the contents of loca-
  1338. *                                tions 'START' and 'START'+1.
  1339. *
  1340. *  Register Usage:
  1341. *     CC = reflects value incremented (Z-bit only).
  1342. *     All other registers preserved.
  1343. *
  1344. *  Notes:
  1345. *    1. <address> may be direct or extended!
  1346. *    2. This macro essentially performs a "SUB n" function.
  1347. *
  1348. DEC.W  MACR
  1349.    IFEQ    NARG-1
  1350.          STA     TEMPA$
  1351.          LDA     (\0)+1
  1352.          SUB     #1
  1353.          STA     (\0)+1
  1354.          LDA     \0
  1355.          SBC     #0
  1356.          STA     \0
  1357.          ORA     (\0)+1
  1358.          STA     TESTA$
  1359.          LDA     TEMPA$
  1360.          TST     TESTA$
  1361.          MEXIT
  1362.    ENDC
  1363.    IFEQ    NARG-2
  1364.          STA     TEMPA$
  1365.          LDA     (\1)+1
  1366.          SUB     (\0)+1
  1367.          STA     (\1)+1
  1368.          LDA     \1
  1369.          SBC     \0
  1370.          STA     \1
  1371.          ORA     (\1)+1
  1372.          STA     TESTA$
  1373.          LDA     TEMPA$
  1374.          TST     TESTA$
  1375.          MEXIT
  1376.    ENDC
  1377.    IFEQ    NARG-3
  1378.      IFC     '\0','#'
  1379.          STA     TEMPA$
  1380.          LDA     (\2)+1
  1381.          SUB     #(\1)!.$FF
  1382.          STA     (\2)+1
  1383.          LDA     \2
  1384.          SBC     #(\1)!>8
  1385.          STA     \2
  1386.          ORA     (\2)+1
  1387.          STA     TESTA$
  1388.          LDA     TEMPA$
  1389.          TST     TESTA$
  1390.          MEXIT
  1391.      ENDC
  1392.    ENDC
  1393.          FAIL    Macro syntax error detected!
  1394.        ENDM
  1395.  
  1396. **************************************************************************
  1397. *  INC.B = increment byte
  1398. *      INC.B  [[#,]<value>,]<address>
  1399. *
  1400. *  where:
  1401. *     <value>    = value to decrement the contents of the <address>
  1402. *                  location by; immediate ("#," present) or absolute
  1403. *                  addressing ("#," not present).  If only <address> is
  1404. *                  specified, a default immediate value of one is used.
  1405. *
  1406. *  Examples:
  1407. *     1. "INC.B  START"          adds one to the contents of location
  1408. *                                'START'.
  1409. *     2. "INC.B  #,5,START"      adds five to the contents of location
  1410. *                                'START'.
  1411. *     3. "INC.B  CNT,START"      adds the contents of location 'CNT' to
  1412. *                                the contents of location 'START'.
  1413. *
  1414. *  Register Usage:
  1415. *     CC = reflects value incremented (N and Z-bits).
  1416. *     All other registers preserved.
  1417. *
  1418. *  Notes:
  1419. *    1. <address> may be direct or extended!
  1420. *    2. This macro essentially performs an "ADD n" function.
  1421. *
  1422. INC.B  MACR
  1423.    IFEQ    NARG-1
  1424.      IFEQ    (\0)!.$FF00
  1425.          INC     \0
  1426.          MEXIT
  1427.      ENDC
  1428.          STA     TEMPA$
  1429.          LDA     \0
  1430.          ADD     #1
  1431.          STA     \0
  1432.          STA     TESTA$
  1433.          LDA     TEMPA$
  1434.          TST     TESTA$
  1435.          MEXIT
  1436.    ENDC
  1437.    IFEQ    NARG-2
  1438.          STA     TEMPA$
  1439.          LDA     \1
  1440.          ADD     \0
  1441.          STA     \1
  1442.      IFEQ    (\1)!.$FF00
  1443.          LDA     TEMPA$
  1444.          TST     \1
  1445.          MEXIT
  1446.      ENDC
  1447.      IFNE    (\1)!.$FF00
  1448.          STA     TESTA$
  1449.          LDA     TEMPA$
  1450.          TST     TESTA$
  1451.          MEXIT
  1452.      ENDC
  1453.    ENDC
  1454.    IFEQ    NARG-3
  1455.      IFC     '\0','#'
  1456.          STA     TEMPA$
  1457.          LDA     \2
  1458.          ADD     #\1
  1459.          STA     \2
  1460.        IFEQ    (\2)!.$FF00
  1461.          LDA     TEMPA$
  1462.          TST     \2
  1463.          MEXIT
  1464.        ENDC
  1465.        IFNE    (\2)!.$FF00
  1466.          STA     TESTA$
  1467.          LDA     TEMPA$
  1468.          TST     TESTA$
  1469.          MEXIT
  1470.        ENDC
  1471.      ENDC
  1472.    ENDC
  1473.          FAIL    Macro syntax error detected!
  1474.        ENDM
  1475.  
  1476. **************************************************************************
  1477. *  INC.W = increment word
  1478. *      INC.W  [[#,]<value>,]<address>
  1479. *
  1480. *  where:
  1481. *     <value>    = value to increment the contents of the <address> and
  1482. *                  <address>+1 locations by; immediate ("#," present)
  1483. *                  or absolute addressing ("#," not present).  If only
  1484. *                  <address> is specified, a default immediate value of
  1485. *                  one is used.
  1486. *
  1487. *  Examples:
  1488. *     1. "INC.W  START"          adds one to the contents of locations
  1489. *                                'START' and 'START'+1.
  1490. *     2. "INC.W  CNT,START"      adds the value of 'CNT' to the contents
  1491. *                                of locations 'START' and 'START'+1.
  1492. *     3. "INC.W  #,5,START"      adds five to the contents of locations
  1493. *                                'START' and 'START'+1.
  1494. *
  1495. *  Register Usage:
  1496. *     CC = reflects value incremented (Z-bit only).
  1497. *     All other registers preserved.
  1498. *
  1499. *  Notes:
  1500. *    1. <address> may be direct or extended!
  1501. *    2. This macro essentially performs an "ADD n" function.
  1502. *
  1503. INC.W  MACR
  1504.    IFEQ    NARG-1
  1505.      IFEQ    (\0)!.$FF00
  1506.          INC     (\0)+1
  1507.          BNE     \.0
  1508.          INC     \0
  1509. \.0      EQU     *
  1510.          MEXIT
  1511.      ENDC
  1512.      IFNE    (\0)!.$FF00
  1513.          STA     TEMPA$
  1514.          LDA     (\0)+1
  1515.          ADD     #1
  1516.          STA     (\0)+1
  1517.          LDA     \0
  1518.          ADC     #0
  1519.          STA     \0
  1520.          ORA     (\0)+1
  1521.          STA     TESTA$
  1522.          LDA     TEMPA$
  1523.          TST     TESTA$
  1524.          MEXIT
  1525.      ENDC
  1526.    ENDC
  1527.    IFEQ    NARG-2
  1528.          STA     TEMPA$
  1529.          LDA     (\1)+1
  1530.          ADD     (\0)+1
  1531.          STA     (\1)+1
  1532.          LDA     \1
  1533.          ADC     \0
  1534.          STA     \1
  1535.          ORA     (\1)+1
  1536.          STA     TESTA$
  1537.          LDA     TEMPA$
  1538.          TST     TESTA$
  1539.          MEXIT
  1540.    ENDC
  1541.    IFEQ    NARG-3
  1542.      IFC     '\0','#'
  1543.          STA     TEMPA$
  1544.          LDA     (\2)+1
  1545.          ADD     #(\1)!.$FF
  1546.          STA     (\2)+1
  1547.          LDA     \2
  1548.          ADC     #(\1)!>8
  1549.          STA     \2
  1550.          ORA     (\2)+1
  1551.          STA     TESTA$
  1552.          LDA     TEMPA$
  1553.          TST     TESTA$
  1554.          MEXIT
  1555.      ENDC
  1556.    ENDC
  1557.          FAIL    Macro syntax error detected!
  1558.        ENDM
  1559.  
  1560. **************************************************************************
  1561. *  MOV.B = move byte
  1562. *      MOV.B  [#,]<byte>,<address>
  1563. *
  1564. *  where:
  1565. *     <byte>     = byte value to move to the <address> location, using
  1566. *                  immediate ("#," present) or absolute addressing ("#,"
  1567. *                  not present).
  1568. *
  1569. *  Examples:
  1570. *     1. "MOV.B  CNT,TMP"        puts the contents of location 'CNT'
  1571. *                                into location 'TMP'.
  1572. *     2. "MOV.B  #,5,START"      puts 5 into location 'START'.
  1573. *
  1574. *  Register Usage:
  1575. *     CC = reflects value moved.
  1576. *     All other registers preserved.
  1577. *
  1578. MOV.B  MACR
  1579.    IFEQ    NARG-2
  1580.          STA     TEMPA$
  1581.          LDA     \0
  1582.          STA     \1
  1583.      IFEQ    (\1)!.$FF00
  1584.          LDA     TEMPA$
  1585.          TST     \1
  1586.          MEXIT
  1587.      ENDC
  1588.      IFNE    (\1)!.$FF00
  1589.        IFEQ    (\0)!.$FF00
  1590.          LDA     TEMPA$
  1591.          TST     \0
  1592.          MEXIT
  1593.        ENDC
  1594.        IFNE    (\0)!.$FF00
  1595.          STA     TESTA$
  1596.          LDA     TEMPA$
  1597.          TST     TESTA$
  1598.          MEXIT
  1599.        ENDC
  1600.      ENDC
  1601.    ENDC
  1602.    IFEQ    NARG-3
  1603.      IFC     '\0','#'
  1604.        IFEQ    (\2)!.$FF00
  1605.          IFEQ    \1
  1606.            CLR     \2
  1607.            MEXIT
  1608.          ENDC
  1609.        ENDC
  1610.          STA     TEMPA$
  1611.        IFEQ    \1
  1612.          CLRA
  1613.        ENDC
  1614.        IFNE    \1
  1615.          LDA     #\1
  1616.        ENDC
  1617.          STA     \2
  1618.        IFEQ    (\2)!.$FF00
  1619.          LDA     TEMPA$
  1620.          TST     \2
  1621.          MEXIT
  1622.        ENDC
  1623.        IFNE    (\2)!.$FF00
  1624.          STA     TESTA$
  1625.          LDA     TEMPA$
  1626.          TST     TESTA$
  1627.          MEXIT
  1628.        ENDC
  1629.      ENDC
  1630.    ENDC
  1631.          FAIL    Macro syntax error detected!
  1632.        ENDM
  1633.  
  1634. **************************************************************************
  1635. *  MOV.W = move word
  1636. *      MOV.W  [#,]<word>,<address>
  1637. *
  1638. *  where:
  1639. *     <word>     = word (16-bit) value to move to the <address> and
  1640. *                  <address>+1 locations, using immediate ("#," present)
  1641. *                  or absolute addressing ("#," not present).
  1642. *
  1643. *  Examples:
  1644. *     1. "MOV.W  #,5,START"      puts $0005 into location 'START' and
  1645. *                                'START'+1.
  1646. *     2. "MOV.W  #,CNT,TMP"      puts the value of symbol 'CNT' into
  1647. *                                locations 'TMP' and 'TMP'+1.
  1648. *     3. "MOV.W  CNT,TMP"        copies the contents of location 'CNT'
  1649. *                                and 'CNT'+1 into locations 'TMP' and
  1650. *                                'TMP'+1.
  1651. *
  1652. *  Register Usage:
  1653. *     CC = reflects MS half of value moved.
  1654. *     All other registers preserved.
  1655. *
  1656. MOV.W  MACR
  1657.    IFEQ    NARG-2
  1658.          STA     TEMPA$
  1659.          LDA     (\0)+1
  1660.          STA     (\1)+1
  1661.          LDA     \0
  1662.          STA     \1
  1663.      IFEQ    (\1)!.$FF00
  1664.          LDA     TEMPA$
  1665.          TST     \1
  1666.          MEXIT
  1667.      ENDC
  1668.      IFNE    (\1)!.$FF00
  1669.        IFEQ    (\0)!.$FF00
  1670.          LDA     TEMPA$
  1671.          TST     \0
  1672.          MEXIT
  1673.        ENDC
  1674.        IFNE    (\0)!.$FF00
  1675.          STA     TESTA$
  1676.          LDA     TEMPA$
  1677.          TST     TESTA$
  1678.          MEXIT
  1679.        ENDC
  1680.      ENDC
  1681.    ENDC
  1682.    IFEQ    NARG-3
  1683.      IFC     '\0','#'
  1684.        IFEQ    ((\2)+1)!.$FF00
  1685.          IFEQ    \1
  1686.            CLR     \2
  1687.            CLR     \2+1
  1688.            MEXIT
  1689.          ENDC
  1690.        ENDC
  1691.            STA     TEMPA$
  1692.        IFEQ    (\1)!.$00FF
  1693.            CLRA
  1694.        ENDC
  1695.        IFNE    (\1)!.$00FF
  1696.            LDA     #(\1)!.$00FF
  1697.        ENDC
  1698.            STA     (\2)+1
  1699.        IFEQ    (\1)!>8
  1700.          IFNE    (\1)!.$00FF
  1701.            CLRA
  1702.          ENDC
  1703.        ENDC
  1704.        IFNE    (\1)!>8
  1705.            LDA     #(\1)!>8
  1706.        ENDC
  1707.            STA     \2
  1708.        IFEQ    (\2)!.$FF00
  1709.            LDA     TEMPA$
  1710.            TST     \2
  1711.            MEXIT
  1712.        ENDC
  1713.        IFNE    (\2)!.$FF00
  1714.            STA     TESTA$
  1715.            LDA     TEMPA$
  1716.            TST     TESTA$
  1717.            MEXIT
  1718.        ENDC
  1719.      ENDC
  1720.    ENDC
  1721.          FAIL    Macro syntax error detected!
  1722.        ENDM
  1723.  
  1724. **************************************************************************
  1725. *  MOVE = move block of memory
  1726. *      MOVE   [#],<source>,[#],<destination>,[#],<length>
  1727. *
  1728. *  where:
  1729. *          <source>        is the address of the source memory block.
  1730. *          <destination>   is the address of the destination block.
  1731. *          <length>        is the length of the block to move, in bytes.
  1732. *                          Maximum of 65,536 bytes can be moved.
  1733. *          #               is optional character to denote immediate
  1734. *                          addressing for the next parameter
  1735. *  Examples:
  1736. *     1. "MOVE  #,ROM,#,RAM,#,CNT  moves the block of memory starting at
  1737. *                                  location 'ROM' for 'CNT' bytes, to
  1738. *                                  location 'RAM'.
  1739. *     2. "MOVE  #,ABC,#,XYZ,,CNT   moves the block of memory starting at
  1740. *                                  location 'ABC' for the number of bytes
  1741. *                                  in locations 'CNT' and 'CNT'+1, to
  1742. *                                  location 'XYZ'.
  1743. *
  1744. *  Register Usage:
  1745. *     CC  = unknown.
  1746. *     All other registers preserved.
  1747. *
  1748. *  Subr. used:
  1749. *     LDAXREG, STAXREG
  1750. *
  1751. *  Macros used:
  1752. *     None, because this macro was written to be as efficient as
  1753. *     possible.
  1754. *
  1755. *  Notes:
  1756. *    1. If all immediate addressing operands (#) and the move count is
  1757. *       <= 256, then a special 'short form' is generated which DOES NOT
  1758. *       contain any subroutine calls!
  1759. *    2. Depending on the exact parameters passed, not all registers,
  1760. *       subroutines and/or macros may be used.
  1761. *    3. This macro takes advantage of the fact that there are in fact
  1762. *       two XREGs, one for LOAD (XREG1$) and one for STORE (XREG2$).
  1763. *    4. The INCXR macro cannot be used here, because it assumes that
  1764. *       XREG1$ = XREG2$.
  1765. *-------------------------------------------------------------------------
  1766. MOVE   MACR
  1767.          IFNE    NARG-6
  1768.            FAIL    ** 'move' macro requires six arguments!
  1769.          ENDC
  1770.    IFC     '\4','#'          ! If all immediate operands (#) and move
  1771.      IFC     '\2','#'        ! count <=256, use short form!
  1772.        IFC     '\0','#'
  1773.          IFLE    \5-256      ! No subr. calls!
  1774.            STA     TEMPA$
  1775.            STX     TEMPX$
  1776.            LDX     #(\5)
  1777. \.0        LDA     (\1)-1,x
  1778.            STA     (\3)-1,x
  1779.            DEX
  1780.            BNE     \.0
  1781.            LDA     TEMPA$
  1782.            LDX     TEMPX$
  1783.            MEXIT
  1784.          ENDC
  1785.        ENDC
  1786.      ENDC
  1787.    ENDC
  1788.  
  1789.          STA     TEMPA$
  1790.          STX     TEMPX$
  1791.          LDA     XREG1$
  1792.          STA     TEMPXR$
  1793.          LDA     XREG1$+1
  1794.          STA     TEMPXR$+1
  1795.    IFC     '\0','#'        ! immediate type 'from' address?
  1796.          LDA     #(\1)!.$FF
  1797.          STA     XREG1$+1  ! Set XREG1$ = 'from' address
  1798.          LDA     #(\1)!>8
  1799.          STA     XREG1$
  1800.    ENDC
  1801.    IFNC    '\0','#'        ! not immediate type 'from' address?
  1802.          LDA     (\1)+1
  1803.          STA     XREG1$+1  ! Set XREG1$ = 'from' address
  1804.          LDA     (\1)
  1805.          STA     XREG1$
  1806.    ENDC
  1807.    IFC     '\2','#'        ! immediate type 'to' address?
  1808.          LDA     #(\3)!.$FF
  1809.          STA     XREG2$+1  ! Set XREG2$ = 'to' address
  1810.          LDA     #(\3)!>8
  1811.          STA     XREG2$
  1812.    ENDC
  1813.    IFNC    '\2','#'        ! not immediate type 'to' address?
  1814.          LDA     (\3)+1
  1815.          STA     XREG2$+1  ! Set XREG2$ = 'to' address
  1816.          LDA     (\3)
  1817.          STA     XREG2$
  1818.    ENDC
  1819.  
  1820.    IFC     '\4','#'        ! immediate type length?
  1821.      IFLE    \5-256          !   yes:  8-bit size= use X reg.
  1822.          LDX     #(\5)
  1823. \.0      JSR     LDAXREG
  1824.          JSR     STAXREG
  1825.        IFEQ    XREG1$!.$FF00
  1826.          INC     XREG1$+1
  1827.          BNE     \.1
  1828.          INC     XREG1$
  1829. \.1      INC     XREG2$+1
  1830.          BNE     \.2
  1831.          INC     XREG2$
  1832. \.2      EQU     *
  1833.        ENDC
  1834.        IFNE    XREG1$!.$FF00
  1835.          LDA     XREG1$+1
  1836.          ADD     #1
  1837.          STA     XREG1$+1
  1838.          LDA     XREG1$
  1839.          ADC     #0
  1840.          STA     XREG1$
  1841.          LDA     XREG2$+1
  1842.          ADD     #1
  1843.          STA     XREG2$+1
  1844.          LDA     XREG2$
  1845.          ADC     #0
  1846.          STA     XREG2$
  1847.        ENDC
  1848.          DEX
  1849.          BNE     \.0
  1850.          LDA     TEMPXR$
  1851.          STA     XREG1$
  1852.          STA     XREG2$
  1853.          LDA     TEMPXR$+1
  1854.          STA     XREG1$+1
  1855.          STA     XREG2$+1
  1856.          LDA     TEMPA$
  1857.          LDX     TEMPX$
  1858.          MEXIT
  1859.      ENDC
  1860. *
  1861.      IFGT    \5-256          !    no: 16-bit size= use 'length'
  1862.          LDA     #(\5)!.$00FF
  1863.          STA     LENGTH$+1
  1864.          LDA     #(\5)!>8
  1865.          STA     LENGTH$
  1866. \.0      JSR     LDAXREG
  1867.          JSR     STAXREG
  1868.        IFEQ    XREG1$!.$FF00
  1869.          INC     XREG1$+1
  1870.          BNE     \.1
  1871.          INC     XREG1$
  1872. \.1      INC     XREG2$+1
  1873.          BNE     \.2
  1874.          INC     XREG2$
  1875. \.2      EQU     *
  1876.        ENDC
  1877.        IFNE    XREG1$!.$FF00
  1878.          LDA     XREG1$+1
  1879.          ADD     #1
  1880.          STA     XREG1$+1
  1881.          LDA     XREG1$
  1882.          ADC     #0
  1883.          STA     XREG1$
  1884.          LDA     XREG2$+1
  1885.          ADD     #1
  1886.          STA     XREG2$+1
  1887.          LDA     XREG2$
  1888.          ADC     #0
  1889.          STA     XREG2$
  1890.        ENDC
  1891.          LDA     LENGTH$+1
  1892.          SUB     #1
  1893.          STA     LENGTH$+1
  1894.          LDA     LENGTH$
  1895.          SBC     #0
  1896.          STA     LENGTH$
  1897.          ORA     LENGTH$+1
  1898.          BNE     \.0
  1899.          LDA     TEMPXR$
  1900.          STA     XREG1$
  1901.          STA     XREG2$
  1902.          LDA     TEMPXR$+1
  1903.          STA     XREG1$+1
  1904.          STA     XREG2$+1
  1905.          LDA     TEMPA$
  1906.          LDX     TEMPX$
  1907.          MEXIT
  1908.      ENDC
  1909.    ENDC
  1910.  
  1911.    IFNC    '\4','#'        ! nonimmediate type length
  1912.          LDA     (\5)!.$00FF
  1913.          STA     LENGTH$+1
  1914.          LDA     (\5)!>8
  1915.          STA     LENGTH$
  1916. \.0      JSR     LDAXREG
  1917.          JSR     STAXREG
  1918.      IFEQ    XREG1$!.$FF00
  1919.          INC     XREG1$+1
  1920.          BNE     \.1
  1921.          INC     XREG1$
  1922. \.1      INC     XREG2$+1
  1923.          BNE     \.2
  1924.          INC     XREG2$
  1925. \.2      EQU     *
  1926.      ENDC
  1927.      IFNE    XREG1$!.$FF00
  1928.          LDA     XREG1$+1
  1929.          ADD     #1
  1930.          STA     XREG1$+1
  1931.          LDA     XREG1$
  1932.          ADC     #0
  1933.          STA     XREG1$
  1934.          LDA     XREG2$+1
  1935.          ADD     #1
  1936.          STA     XREG2$+1
  1937.          LDA     XREG2$
  1938.          ADC     #0
  1939.          STA     XREG2$
  1940.      ENDC
  1941.          LDA     LENGTH$+1
  1942.          SUB     #1
  1943.          STA     LENGTH$+1
  1944.          LDA     LENGTH$
  1945.          SBC     #0
  1946.          STA     LENGTH$
  1947.          ORA     LENGTH$+1
  1948.          BNE     \.0
  1949.          LDA     TEMPXR$
  1950.          STA     XREG1$
  1951.          STA     XREG2$
  1952.          LDA     TEMPXR$+1
  1953.          STA     XREG1$+1
  1954.          STA     XREG2$+1
  1955.          LDA     TEMPA$
  1956.          LDX     TEMPX$
  1957.          MEXIT
  1958.    ENDC
  1959.          FAIL    Macro syntax error detected!
  1960.        ENDM
  1961.  
  1962.  
  1963.          OPT    L
  1964. RAMSBR$  EQU    *           Start of RAM based subroutines!
  1965. **************************************************************************
  1966. **  The following RAM subroutines MUST BE INITIALIZED from ROM upon     **
  1967. **  startup (from 'RAMSBR$' for 'RAMSZ$' number of bytes).  If changes  **
  1968. **  are to be made to the RAM subroutines, make them here.  Then copy   **
  1969. **  the source below to the ROM area and insert a '.' in front of all   **
  1970. **  the labels (leading '.' will be used to denote ROM).  This has      **
  1971. **  already been done for you in the RAMSBR.INI file.  Just include     **
  1972. **  this file into your ROM data area and add the following line in     **
  1973. **  your RESET routine to initialize the RAM subroutines from the ROM.  **
  1974. **                MOVE   #,.RAMSBR,#,RAMSBR,#,RAMSZ$                    **
  1975. **  It is more efficient if the RAM subroutines are placed in DIRECT    **
  1976. **  addressing memory, i.e., $0000-$00FF, but it is not required.       **
  1977. **************************************************************************
  1978.  
  1979. *-- start of RAM subroutines --------------------------------------------*
  1980. **************************************************************************
  1981. *  LDAXREG = load A via XREG subr.
  1982. *
  1983. *  Register Usage:
  1984. *     CC = reflects value loaded.
  1985. *     All other registers preserved.
  1986. *
  1987. *  NOTE:
  1988. *    1. Instruction modified code here must be located in RAM!
  1989. *
  1990. LDAXREG  EQU    *
  1991.          LDA    0-0+$FFFF
  1992. XREG1$   EQU    *-2         Pseudo XREG #1
  1993.          RTS
  1994.  
  1995. **************************************************************************
  1996. *  STAXREG = store A via XREG subr.
  1997. *
  1998. *  Register Usage:
  1999. *     CC = reflects value stored.
  2000. *     All other registers preserved.
  2001. *
  2002. *  NOTE:
  2003. *    1. Instruction modified code here must be located in RAM!
  2004. *
  2005. STAXREG  EQU    *
  2006.          STA    0-0+$FFFF
  2007. XREG2$   EQU    *-2         Pseudo XREG #2
  2008.          RTS
  2009.  
  2010. **************************************************************************
  2011. *  LDAYREG = load A via YREG subr.
  2012. *
  2013. *  Register Usage:
  2014. *     CC = reflects value loaded.
  2015. *     All other registers preserved.
  2016. *
  2017. *  NOTE:
  2018. *    1. Instruction modified code here must be located in RAM!
  2019. *
  2020. LDAYREG  EQU    *
  2021.          LDA    0-0+$FFFF
  2022. YREG1$   EQU    *-2         Pseudo YREG #1
  2023.          RTS
  2024.  
  2025. **************************************************************************
  2026. *  STAYREG = store A via YREG subr.
  2027. *
  2028. *  Register Usage:
  2029. *     CC = reflects value stored.
  2030. *     All other registers preserved.
  2031. *
  2032. *  NOTE:
  2033. *    1. Instruction modified code here must be located in RAM!
  2034. *
  2035. STAYREG  EQU    *
  2036.          STA    0-0+$FFFF
  2037. YREG2$   EQU    *-2         Pseudo YREG #2
  2038.          RTS
  2039. *-- end of RAM subroutines ----------------------------------------------*
  2040.  
  2041. RAMSZ$   EQU    *-RAMSBR$   Size of ram subroutines (in bytes).
  2042.  
  2043.          ORG    LO$MEM
  2044. * NOTE: TEMPA$ and TESTA$ must always be in low memory $0000-00FF.
  2045. TEMPA$   RMB    1           Temporary storage for A accumulator.
  2046. TEMPX$   RMB    1           Temporary storage for X register.
  2047. TEMPXR$  RMB    2           Temporary storage for XREG register.
  2048. TESTA$   RMB    1           Temporary operand storage for setting CC bits.
  2049. LENGTH$  RMB    2           Temporary operand length.
  2050.  
  2051. **************************************************************************
  2052.